package com.logic.landseaserver.ws.dto;

import java.sql.Timestamp;
import java.util.Date;

public class RoomPicDTO {
	private Integer id;

    private Integer projectId;

    private Integer estateId;

    private String roomType;

	private String coverImage;

    private String detailImages;

    private Integer version;

    private Date createdDtm;

	private Integer createdBy;

    private Date lastModifiedDtm;

    private Integer lastModifiedBy;

    private Boolean deleted;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getProjectId() {
		return projectId;
	}

	public void setProjectId(Integer projectId) {
		this.projectId = projectId;
	}

	public Integer getEstateId() {
		return estateId;
	}

	public void setEstateId(Integer estateId) {
		this.estateId = estateId;
	}

	public String getRoomType() {
		return roomType;
	}

	public void setRoomType(String roomType) {
		this.roomType = roomType;
	}

	public String getCoverImage() {
		return coverImage;
	}

	public void setCoverImage(String coverImage) {
		this.coverImage = coverImage;
	}

	public String getDetailImages() {
		return detailImages;
	}

	public void setDetailImages(String detailImages) {
		this.detailImages = detailImages;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public Date getCreatedDtm() {
		return createdDtm;
	}

	public void setCreatedDtm(Date createdDtm) {
		this.createdDtm = createdDtm;
	}

	public Integer getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(Integer createdBy) {
		this.createdBy = createdBy;
	}

	public Date getLastModifiedDtm() {
		return lastModifiedDtm;
	}

	public void setLastModifiedDtm(Date lastModifiedDtm) {
		this.lastModifiedDtm = lastModifiedDtm;
	}

	public Integer getLastModifiedBy() {
		return lastModifiedBy;
	}

	public void setLastModifiedBy(Integer lastModifiedBy) {
		this.lastModifiedBy = lastModifiedBy;
	}

	public Boolean getDeleted() {
		return deleted;
	}

	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}
    public void updateCommonInfo(Integer userId) {

        Timestamp now = new Timestamp(new Date().getTime());
        if (this.getId() == null || this.getId() == 0) { // New PoJo
          this.setVersion(0);
          if (this.getCreatedDtm() == null) {
            this.setCreatedDtm(now);
          }
          if (this.getCreatedBy() == null || this.getCreatedBy().equals(0)) {
            this.setCreatedBy(userId == null ? 0 : userId);
          }
          this.setLastModifiedDtm(now);
          this.setLastModifiedBy(userId == null ? 0 : userId);
          this.setDeleted(false);

        } else { // Update this
          this.setVersion(this.getVersion() == null ? 1 : this.getVersion() + 1);
          this.setLastModifiedDtm(now);
          if (userId.equals(-1)) {
          } else {
            this.setLastModifiedBy(userId == null ? 0 : userId);
          }
        }
      }
    

}
